import { get } from "@/api/request";
export * from "./oss.js";
async function createdUploader(params) {
    const authData = await get("/user/cu/sys/base/js-auth-sts");
    const uploader = new AliyunUpload.Vod({
        userId: "247663324860467118",
        onUploadstarted(uploadInfo) {
            uploader.setSTSToken(
                uploadInfo,
                authData.accessKeyId,
                authData.accessKeySecret,
                authData.stsToken
            );
        },
        onUploadSucceed(uploadInfo) {
            console.log("uploadInfo:", uploadInfo);
            params.success({
                videoId: uploadInfo.videoId,
                size: uploadInfo.file.size,
                fileName: uploadInfo.videoInfo.FileName,
                title: uploadInfo.videoInfo.Title,
                type: uploadInfo.file.type,
                file: uploadInfo.file,
            });
        },
        onUploadFailed(uploadInfo, code, message) {},
        // 文件上传进度，单位：字节
        onUploadProgress(uploadInfo, totalSize, loadedPercent) {
            params.progress && params.progress(loadedPercent);
        },
        // STS token超时
        onUploadTokenExpired(uploadInfo) {
            uploader.resumeUploadWithAuth(authData.body.uploadAuth);
        },
        // 全部文件上传结束
        onUploadEnd(uploadInfo) {},
        ...params,
    });
    return uploader;
}
